<template>
	<view>
		<scroll-view :scroll-y="true" @scrolltolower="scrollBottom">
			<view class="list" v-for="item in collectiondata">
				<Post></Post>
			</view>
			<uni-load-more :status="scrollInfo.loading"></uni-load-more>
		</scroll-view>
	</view>
</template>

<script lang="ts" setup>
	import Post from '../../components/post/post.vue'
	import { ref, onMounted, reactive } from 'vue'
	import { GetCollection, PostConcern } from '../../apis/user'
	import userStore from '../../store/modules/user'
	const useStore = userStore();
	let collectiondata = ref()
	let page = ref('1')
	let limit = ref('10')

	const scrollInfo = reactive({
		loading: "more",
	})
	onMounted(() => {
		GetCollectionData()
	})


	const clickFollow = async function (e : number) {
		try {
			const res = await PostConcern(user_id);
			console.log(res);
		} catch (error) {
			// 错误处理逻辑
			console.error('An error occurred while executing Captcha function:', error);
		}
	}


	const GetCollectionData = async function () {
		const data = {
			user_id: useStore.user_id,
			page: page.value,
			limit: limit.value
		}
		try {
			const res = await GetCollection(data);
			collectiondata.value = res.data
			console.log(collectiondata.value);
		} catch (error) {
			// 错误处理逻辑
			console.error('An error occurred while executing Captcha function:', error);
		}
	}
	//到底加载请求
	function scrollBottom() {
		console.log("滚动到底部!");
		page.value = (parseInt(page.value) + 1).toString();
		scrollInfo.loading = "loading";
		GetCollectionData();
	}
</script>

<style lang="scss">

</style>